#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 1e6 + 5;
const int MOD = 1e9;

int n, k;
int a[N];
ll sum[N];
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> k;
  rep(i, 1, k) a[i] = 1, sum[i] = (sum[i - 1] + a[i]) % MOD;
  rep(i, k + 1, n + 1) {
    a[i] = (sum[i - 1] - sum[i - k - 1] + MOD) % MOD;
    sum[i] = (sum[i - 1] + a[i]) % MOD;
  }
  cout << a[n + 1];
  return 0;
}